@cachly-dev/mcp-server 0.10.254 → 0.10.256
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/src/ambient-hook.js +3 -3
- package/dist/src/einblendung.js +7 -7
- package/dist/src/index.js +47 -47
- package/glama.json +1 -1
- package/hooks/cachly-ambient-einblendung.mjs +27 -27
- package/package.json +1 -1
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -55,11 +55,11 @@ creates your Brain on first start. The [JetBrains plugin](https://plugins.jetbra
|
|
|
55
55
|
brings it to IntelliJ IDEA, PyCharm, GoLand, WebStorm and Rider
|
|
56
56
|
([guide](https://cachly.dev/docs/jetbrains)).
|
|
57
57
|
|
|
58
|
-
**
|
|
59
|
-
and the Brain moves into your account with all its lessons.
|
|
58
|
+
**Already have a test Brain?** Keep it with `npx @cachly-dev/mcp-server@latest claim`. You sign in
|
|
59
|
+
once, and the Brain moves into your account with all its lessons.
|
|
60
60
|
|
|
61
61
|
<details>
|
|
62
|
-
<summary><b>Claude Code in detail:</b> the three hooks, auto-update, and the
|
|
62
|
+
<summary><b>Claude Code in detail:</b> the three hooks, auto-update, and the sign-in</summary>
|
|
63
63
|
|
|
64
64
|
The plugin adds three Claude Code hooks:
|
|
65
65
|
|
|
@@ -74,8 +74,8 @@ Claude Code leaves it off for marketplaces outside Anthropic's own. The MCP serv
|
|
|
74
74
|
itself on every start; the hooks come with the plugin and update with it. If an update is
|
|
75
75
|
waiting, the first `session_start` of a session says so in one line.
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
Without a key, the first tool call opens your browser once to sign in (GitHub, Google or
|
|
78
|
+
e-mail). `claude mcp list` is the reliable check: `claude plugin details`
|
|
79
79
|
shows `MCP servers (0)` even while the server runs.
|
|
80
80
|
|
|
81
81
|
`claim` revokes every test key and stores a new key where your editor and hooks look for
|
|
@@ -415,7 +415,7 @@ Manual snippets are in [Manual Setup](#manual-setup).
|
|
|
415
415
|
|
|
416
416
|
| Editor / client | Auto-setup | Config file written | Global config | Notes |
|
|
417
417
|
|---|---|---|---|---|
|
|
418
|
-
| **Claude Code** | yes | `.mcp.json` | with the plugin | Without a key:
|
|
418
|
+
| **Claude Code** | yes | `.mcp.json` | with the plugin | Without a key: the first tool call opens the browser once to sign in |
|
|
419
419
|
| **Cursor** | yes, detected via `.cursor/` | `.cursor/mcp.json`, hooks in `.cursor/hooks.json` | no | Project-level; restart Cursor after setup. Lessons arrive with the first tool call of a turn |
|
|
420
420
|
| **Windsurf** | yes, detected via `.windsurf/` | `.windsurf/mcp.json` | no | Project-level; restart Windsurf after setup |
|
|
421
421
|
| **VS Code + Copilot** | yes, detected via `.vscode/` | `.vscode/mcp.json`, hooks in `.github/hooks/cachly-ambient.json` | no | Needs the VS Code MCP support or Copilot chat. Briefing at session start, lessons before each prompt |
|
|
@@ -433,7 +433,7 @@ Manual snippets are in [Manual Setup](#manual-setup).
|
|
|
433
433
|
|---|---|
|
|
434
434
|
| `autosetup` or `autopilot` from a terminal (TTY) | OAuth device flow: one click in the browser, the API key is saved automatically |
|
|
435
435
|
| `autosetup` from a VS Code task or CI (no TTY) | Detects the non-interactive run, opens the browser with a step-by-step guide, prints the `CACHLY_JWT=... autosetup` command |
|
|
436
|
-
| First tool call without any key |
|
|
436
|
+
| First tool call without any key | Inline device flow: the browser opens once with a URL and a code; sign in with GitHub, Google or e-mail. The key is saved to `~/.cachly/credentials.json` |
|
|
437
437
|
| First tool call with `CACHLY_BRAIN_INSTANCE_ID` set but no key | Inline device flow. You already have a Brain, so no second account is created |
|
|
438
438
|
| `CACHLY_JWT=cky_live_xxx npx ... autosetup` | Skips the sign-in step and uses the key you pass |
|
|
439
439
|
|
package/dist/src/ambient-hook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{readFileSync as
|
|
1
|
+
import{readFileSync as K}from"node:fs";import{tmpdir as y}from"node:os";import{parseHookPayload as O,runEinblendung as j,stopLernanfrage as N,stopObservation as R}from"./ambient-cli.js";import{stopAntwort as M}from"./schreibbeleg.js";import{holeBestand as G,hookAusgabe as B,starteNebenlauf as U}from"./einblendung.js";import{STARTWISSEN_IMPORT as p,hookImportFuerAuftrag as Y,importiereStartwissen as $}from"./startwissen-hook.js";import{belohnungMelden as D}from"./lernen.js";import{appendLedgerEntry as J,reportLedgerEntry as V}from"./ambient-ledger.js";import{copilotHatHook as Q,cursorHatHook as W,findeInstanz as S,findeSchluessel as w,hookUmfeld as _,pluginVersion as X,projektHatHook as q}from"./hook-zugang.js";import{ABKUEHLUNG_HOOK_MS as Z,schreibeAuftrag as L,sichereKonto as tt,startwissenEingeschaltet as v}from"./konto-anlegen.js";import{istInstanzKennung as P,sofortTestHinweis as et}from"./zugang.js";import{CURSOR_FLAG as d,cursorEreignis as T,cursorHookAntwort as nt,cursorLeer as rt,istCursorNutzlast as E}from"./cursor-hook.js";import{COPILOT_FLAG as b,copilotEreignis as ot,copilotHookAntwort as it,istFremdeLaufzeit as F}from"./copilot-hook.js";import{CODEX_FLAG as z,codexHookAntwort as st}from"./codex-hook.js";import{GEMINI_FLAG as k,geminiEreignis as ct,geminiHookAntwort as at}from"./gemini-hook.js";const ut="https://api.cachly.dev",x=5e3,ft="ambient-auffrischen",C=new Set(["SessionStart","UserPromptSubmit","PreToolUse","Stop"]);async function lt(t,e){if(!t.args.includes(d)&&(T(e,t.args)!=="sessionStart"||W(t.umfeld)))return"";const o=t.args.filter(r=>r==="--plugin");return nt({payload:e,args:t.args,claudeLauf:(r,u)=>I({...t,raw:r,args:[u,...o]}),ablageOrdner:t.cursorAblage})}function pt(t,e){const n=(o,r)=>I({...t,raw:o,args:[r]});return t.args.includes(b)?it({payload:e,args:t.args,claudeLauf:n,ablageOrdner:t.copilotAblage}):t.args.includes(z)?st({payload:e,args:t.args,claudeLauf:n}):t.args.includes(k)?at({payload:e,args:t.args,claudeLauf:n}):null}function dt(t,e){return t.includes(d)||E(e)?"cursor":t.includes(b)?"copilot":t.includes(z)?"codex":t.includes(k)?"gemini":F(e)?"vscode":"claude"}async function mt(t){const e=await tt({apiUrl:t.apiUrl,version:X(t.umfeld),home:t.umfeld.heim,env:{...t.umfeld.env,CACHLY_QUELLE:"claude-code-plugin"},fristMs:x,anfrageMs:x,abkuehlungMs:Z,holen:t.fetchFn});if(e.art==="vorhanden")return{apiKey:e.apiKey,instanzId:e.instanzId,hinweis:""};if(e.art!=="angelegt")return null;if(v(t.umfeld.env)){const n={apiUrl:t.apiUrl,jwt:e.test.apiKey,instanceId:e.test.instanzId};t.selbst&&(t.nebenlauf??U)(n,[t.selbst,p,t.umfeld.projekt],{zweck:p,ordner:y()})||L({instanzId:e.test.instanzId,projekt:t.umfeld.projekt},{home:t.umfeld.heim})}return{apiKey:e.test.apiKey,instanzId:e.test.instanzId,hinweis:et(e.test)}}function gt(t,e){const n=e.replace(/^\s+/,"");if(!t)return B("SessionStart",n);try{const o=JSON.parse(t),r=o.hookSpecificOutput?.additionalContext;return!o.hookSpecificOutput||typeof r!="string"?t:(o.hookSpecificOutput.additionalContext=`${n}
|
|
2
2
|
|
|
3
|
-
${r}`,JSON.stringify(o))}catch{return t}}async function I(t){try{const e=
|
|
4
|
-
`);const i=
|
|
3
|
+
${r}`,JSON.stringify(o))}catch{return t}}async function I(t){try{const e=O(t.raw),n={...t,editor:t.editor??dt(t.args,e)};if(n.args.includes(d)||E(e))return await lt(n,e);const o=pt(n,e);if(o)return await o;const r=e?.hook_event_name??n.args.find(i=>C.has(i))??n.umfeld.env.CACHLY_HOOK_EVENT??"";if(F(e)&&(r!=="SessionStart"&&r!=="UserPromptSubmit"||Q(n.umfeld))||n.args.includes("--plugin")&&r&&q(r,n.umfeld))return"";let u=null;if(r==="Stop"&&e?.transcript_path)try{u=K(e.transcript_path,"utf-8").split(`
|
|
4
|
+
`);const i=M(u,e.stop_hook_active===!0);if(i)return i}catch{}let f=w(n.umfeld),c=S(n.umfeld),s="";if(!f&&r==="SessionStart"&&n.args.includes("--plugin")&&!P(c)){const i=await mt(n);i&&(f=i.apiKey,c=i.instanzId??c,s=i.hinweis)}if(!f||!c)return"";const a={apiUrl:n.apiUrl,jwt:f,instanceId:c};if(r==="Stop"){const i=e?R(e):null,h=i?(n.fetchFn??fetch)(`${a.apiUrl}/api/v1/instances/${a.instanceId}/learn`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.jwt}`},body:JSON.stringify(N(i)),signal:AbortSignal.timeout(8e3)}).catch(()=>{}):void 0,l=D(a,e?.session_id??null,u,{fetchFn:n.fetchFn});return await Promise.all([h,l]),""}let m;const g=await(n.einblenden??j)(n.raw,{cfg:a,nebenlauf:n.selbst?[n.selbst,ft]:void 0,editor:n.editor,fetchFn:n.fetchFn,onInject:(i,h)=>{const l={ts:new Date().toISOString(),event:h,injected:i,prevented:0,instanz:a.instanceId};J(l),m=V(a,l,n.fetchFn)}});return m&&await Promise.race([m,new Promise(i=>setTimeout(i,500))]),r==="SessionStart"&&!g&&!s&&n.selbst&&v(n.umfeld.env)&&(n.nebenlauf??U)(a,[n.selbst,p,n.umfeld.projekt],{zweck:p,ordner:y()}),s?gt(g,s):g}catch{return""}}async function ht(){if(process.stdin.isTTY)return"";const t=[];for await(const e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function A(){return process.env.CACHLY_API_URL||ut}const H={SessionStart:25e3,UserPromptSubmit:8e3,PreToolUse:8e3,Stop:5e4,sessionStart:25e3,beforeSubmitPrompt:8e3,postToolUse:3e3,userPromptSubmitted:8e3,PostToolUse:3e3,BeforeAgent:8e3};function St(t,e){return t.includes(d)?rt(T(e,t)):t.includes(b)?ot(e,t)?"{}":"":t.includes(k)&&ct(e,t)?"{}":""}async function Ft(t,e){try{const n=await ht(),o=O(n),r=o?.hook_event_name??t.find(s=>C.has(s)||Object.hasOwn(H,s))??"",u=Number(process.env.CACHLY_HOOK_FRIST_MS)||H[r]||H.UserPromptSubmit,f=St(t,o),c=await Promise.race([I({args:t,raw:n,umfeld:_(),apiUrl:A(),selbst:e}),new Promise(s=>setTimeout(()=>s(f),u))]);c&&await new Promise(s=>process.stdout.write(c,()=>s()))}catch{}process.exit(0)}async function zt(){try{const t=_(),e=w(t),n=S(t);e&&n&&await G({apiUrl:A(),jwt:e,instanceId:n},{force:!0,lernen:!0})}catch{}process.exit(0)}async function xt(t){try{const e=_(),n=w(e),o=S(e);if(n&&P(o)){const r=await $({cfg:{apiUrl:A(),jwt:n,instanceId:o},projekt:t,env:e.env});r.art!=="aus"&&L({instanzId:o,projekt:t,vomHook:Y(r)},{home:e.heim})}}catch{}process.exit(0)}export{ft as AUFFRISCHEN,H as HOOK_FRIST_MS,x as KONTO_FRIST_MS,ut as STANDARD_API_URL,zt as auffrischenHauptlauf,dt as editorVon,I as hookAntwort,Ft as hookHauptlauf,xt as startwissenImportHauptlauf};
|
package/dist/src/einblendung.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{readFileSync as
|
|
1
|
+
import{readFileSync as j,existsSync as C,writeFileSync as R,mkdirSync as F,statSync as W,appendFileSync as V}from"node:fs";import{dirname as $,join as _}from"node:path";import{tmpdir as b}from"node:os";import{createHash as X}from"node:crypto";import{spawn as Q}from"node:child_process";import{Einblendbestand as B,torWoerter as U}from"./einblendung-kern.js";import{rahmeEin as z,RAHMEN_HINWEIS as I}from"./einblendung-rahmen.js";import{istMarkiert as ee}from"./verdacht-marke.js";import{istTeamweit as te}from"./utils.js";import{istBlossesThema as re}from"./blosses-thema.js";import{leserText as ne}from"./seltenheitsbestand.js";import{mischeMitLeser as H}from"./leser.js";import{LeserSicherung as se,dateiSpeicher as oe,frageLeser as ie}from"./leser-sicherung.js";import{LESER_TIEFE_EINBLENDUNG as le,LESER_ZEITLIMIT_MS as ae}from"./rangfolge-stellschrauben.js";import{stufeEinblendungNachVersion as ce}from"./gueltigkeit-version.js";import{ARME as O,BASIS_MIN_BELEGE as ue,MERKMAL_KANDIDATEN as pe,OHNE_LERNEN as fe,entscheide as he,leseArmZaehlung as me,lernEinstellungen as de,lernenAuffrischen as ge,merkeEntscheidung as Ee,neuerSatz as _e,sitzungsKennung as be,zugKennung as ye}from"./lernen.js";export*from"./einblendung-kern.js";import{belohnungMelden as ht,lernenAuffrischen as mt,lernEinstellungen as dt,ARME as gt}from"./lernen.js";const Se=600*1e3,P=300*1e3,Ae=10*1e3,Ne=2e3,Ie=50,ve=60*1e3;function we(e,t){return t<P?{ttlMs:Ae,sofort:!0}:e<Ie?{ttlMs:ve,sofort:!1}:{ttlMs:Se,sofort:!1}}const D=8e3,ke=60*1e3,J=120,K=le,Me=1500,v=ae,Le=_(b(),"cachly-ambient-netlog.jsonl");function rt(e=process.cwd()){const t={apiUrl:process.env.CACHLY_API_URL||"https://api.cachly.dev",jwt:process.env.CACHLY_JWT||"",instanceId:process.env.CACHLY_BRAIN_INSTANCE_ID||""};if(t.jwt&&t.instanceId)return t;let r=e;for(let n=0;n<8;n++){const s=_(r,".mcp.json");if(C(s))try{const i=JSON.parse(j(s,"utf8"))?.mcpServers?.cachly?.env??{};if(t.apiUrl=t.apiUrl||i.CACHLY_API_URL||"https://api.cachly.dev",t.jwt=t.jwt||i.CACHLY_JWT||"",t.instanceId=t.instanceId||i.CACHLY_BRAIN_INSTANCE_ID||"",t.jwt&&t.instanceId)return t}catch{}const o=$(r);if(o===r)break;r=o}return t}function w(e){return X("sha1").update(e).digest("hex").slice(0,12)}function q(e){return _(b(),`cachly-ambient-bestand-${w(e)}.json`)}function xe(e){return _(b(),`cachly-leser-sicherung-${w(e)}.json`)}function Te(e,t="ambient-auffrischen"){return _(b(),`cachly-${t}-${w(e)}.lock`)}async function k(e,{fetchFn:t=fetch,zeitlimitMs:r=D}={}){try{const n=await t(`${e.apiUrl}/api/v1/instances/${e.instanceId}/export`,{headers:{Authorization:`Bearer ${e.jwt}`},signal:AbortSignal.timeout(r)});if(!n.ok)return null;const s=await n.json();return!Array.isArray(s?.lessons)||s.lessons.length===0&&typeof s.note=="string"&&s.note?null:s.lessons.map(o=>typeof o=="string"?je(o):o).filter(o=>!!o&&typeof o=="object")}catch{return null}}function je(e){try{return JSON.parse(e)}catch{return null}}function y(e,t,r="server"){const n=Date.now(),s=S(e),o=s?.seit??n;let i;r==="vorab"?i=t:r==="server"&&s?.vorab&&n-o<P&&(i=s.vorab);const c=r==="server"&&i?Ce(t,i):t;try{F($(e),{recursive:!0}),R(e,JSON.stringify({at:n,seit:o,lessons:c,...i?{vorab:i}:{}}),{mode:384})}catch{}return c}function Ce(e,t){const r=new Set(e.map(n=>n.topic));return[...e,...t.filter(n=>!r.has(n.topic))]}function nt(e,t){if(!e||t.length===0)return!1;const r=q(e);return(S(r)?.lessons.length??0)>0?!1:(y(r,t,"vorab"),!0)}function S(e){try{const t=JSON.parse(j(e,"utf8"));if(Array.isArray(t?.lessons)){const r=Number(t.at)||0;return{at:r,seit:Number(t.seit)||r,lessons:t.lessons,...Array.isArray(t.vorab)?{vorab:t.vorab}:{}}}}catch{}return null}function Re(e,t,{zweck:r,ordner:n}={}){const s=Te(e.instanceId,r);try{if(C(s)&&Date.now()-W(s).mtimeMs<ke)return!1;R(s,String(Date.now()),{mode:384})}catch{return!1}try{return Q(process.execPath,t,{detached:!0,stdio:"ignore",...n?{cwd:n}:{},env:{...process.env,CACHLY_API_URL:e.apiUrl,CACHLY_JWT:e.jwt,CACHLY_BRAIN_INSTANCE_ID:e.instanceId}}).unref(),!0}catch{return!1}}async function $e(e,{force:t=!1,nebenlauf:r,abrufMs:n=D,lernen:s=!1,vorabSchliessen:o=!1,fetchFn:i}={}){if(!e.jwt||!e.instanceId)return{lessons:[],quelle:"nicht-eingerichtet"};const c=q(e.instanceId);if(t){const[u]=await Promise.all([k(e,{fetchFn:i,zeitlimitMs:n}),s?ge(e,{fetchFn:i}):void 0]);if(u)return{lessons:y(c,u,o?"abschluss":"server"),quelle:"server"};const p=S(c);return p?{lessons:p.lessons,quelle:"platte-alt"}:{lessons:[],quelle:"server-nicht-erreichbar"}}const a=S(c);if(a){const u=Date.now(),p=we(a.lessons.length,u-a.seit);if(u-a.at<p.ttlMs)return{lessons:a.lessons,quelle:"platte"};if(p.sofort){const m=await k(e,{fetchFn:i,zeitlimitMs:Math.min(n,Ne)});return m?{lessons:y(c,m),quelle:"server"}:{lessons:a.lessons,quelle:"platte-alt"}}return r&&Re(e,r),{lessons:a.lessons,quelle:"platte-alt"}}const l=await k(e,{fetchFn:i,zeitlimitMs:n});return l?{lessons:y(c,l),quelle:"server"}:{lessons:[],quelle:"server-nicht-erreichbar"}}function M(e){return Math.ceil(String(e).length/4)}function L(e){const t=e.severity?`[${e.severity}] `:"",r=String(e.what_worked??"").replace(/\s+/g," ").trim(),n=r.length>J?`${r.slice(0,J)}\u2026`:r,s=typeof e.versionshinweis=="string"?` [${e.versionshinweis}]`:"";return`- ${t}${e.topic}${s}: ${n}`}const A={lessons:[],tokens:0,topScore:0,belege:0};function x(e,t,r){if(e.length===0)return{...A};const n=[];let s=0;e=ce(e);for(const{lektion:o}of e.slice(0,t)){const i=M(L(o));if(s+i>r)break;n.push(o),s+=i}return{lessons:n,tokens:s,topScore:Math.round(e[0].punkte*100)/100,belege:e[0].belege}}function st(e,t,{minBelege:r=2,topK:n=3,tokenBudget:s=600}={}){if(!Array.isArray(t)||t.length===0)return{...A};if(U(e).length===0)return{...A};const o=new B(t).sortiere(e).filter(i=>i.belege>=r);return o.length===0?{...A}:x(o,n,s)}function Be(e){return ne(e,Me)}async function G(e,t,r,{zeitlimitMs:n=v,fetchFn:s}={}){if(!e?.jwt||!e?.instanceId||r.length===0)return{art:"ohne"};if(["0","off","aus","false"].includes(String(process.env.CACHLY_LESER||"").toLowerCase()))return{art:"ohne"};const o=new se(oe(xe(e.instanceId)));return ie({url:`${e.apiUrl}/api/v1/rerank`,jwt:e.jwt,frage:t,texte:r,instanceId:e.instanceId,zeitlimitMs:n,fetchFn:s},o)}async function ot(e,t,r,n={}){const s=await G(e,t,r,n);return s.art==="punkte"?{scores:s.scores,provider:s.provider,ms:s.ms}:null}async function Y(e,t,r,{minBelege:n,tiefe:s,zeitlimitMs:o,fetchFn:i}){const c={sortiert:[],leser:"aus",leserMs:0};if(!Array.isArray(t)||t.length===0||U(e).length===0)return c;let a=new B(t).sortiere(e).filter(p=>p.belege>=n);if(a.length===0)return c;let l="aus",u=0;if(a.length>1&&s>0){const p=a.slice(0,s),d=a.slice(s),m=await G(r,e,p.map(E=>Be(E.lektion)),{zeitlimitMs:o,fetchFn:i});m.art==="punkte"?(a=[...H(p.map(h=>h.punkte),m.scores,1).map(h=>({...p[h],leser:m.scores[h]})),...d],l=m.provider,u=m.ms):m.art==="uebersprungen"&&(l="uebersprungen")}return{sortiert:a,leser:l,leserMs:u}}async function it(e,t,r,{minBelege:n=2,topK:s=3,tokenBudget:o=600,tiefe:i=K,zeitlimitMs:c=v,fetchFn:a}={}){const l=await Y(e,t,r,{minBelege:n,tiefe:i,zeitlimitMs:c,fetchFn:a});return{...x(l.sortiert,s,o),leser:l.leser,leserMs:l.leserMs}}function Ue(e){if(!e.lessons.length)return"";const t=e.lessons.map(L).join(`
|
|
2
2
|
`);return`\u{1F9E0} Cachly Brain \u2014 relevant lessons for this task (auto-recall, ${e.lessons.length}):
|
|
3
|
-
${
|
|
4
|
-
(ambient-recall \xB7 ~${e.tokens} tokens \xB7 match score ${e.topScore})`}const ze=5;function lt(e){const t=e.filter(l=>!ee(l)&&te(l));if(!t.length)return"";const r=t.filter(l=>{const
|
|
5
|
-
`),o=n.some(l=>(Number(l.recall_count)||0)>0),i=o?"Top by proven reuse":"Starter tips (not yet from your project)",a=o?
|
|
6
|
-
${
|
|
7
|
-
(Relevant lessons for each task are auto-injected per prompt. ~${
|
|
8
|
-
`)}catch{}return{kontext:N,auswahl:
|
|
3
|
+
${z(t)}
|
|
4
|
+
(ambient-recall \xB7 ~${e.tokens} tokens \xB7 match score ${e.topScore})`}const ze=5;function lt(e){const t=e.filter(l=>!ee(l)&&te(l));if(!t.length)return"";const r=t.filter(l=>{const u=String(l.topic??"");return!(/^auto:/.test(u)||re(u))}),n=[...r.length?r:t].sort((l,u)=>(Number(u.recall_count)||0)-(Number(l.recall_count)||0)).slice(0,ze),s=n.map(L).join(`
|
|
5
|
+
`),o=n.some(l=>(Number(l.recall_count)||0)>0),i=!o&&n.some(l=>l.source==="brain_from_git"||Array.isArray(l.tags)&&l.tags.includes("git-history")),c=o?"Top by proven reuse":i?"From this project's git history (not reused yet)":"Starter tips (not yet from your project)",a=o?I:i?I.replace("Stored notes from earlier sessions.","Notes drawn from this project's git history."):I.replace("Stored notes from earlier sessions.","General starter notes, not yet from your project.");return`\u{1F9E0} Cachly Brain \u2014 ambient recall active (${t.length} lessons). ${c}:
|
|
6
|
+
${z(s,a)}
|
|
7
|
+
(Relevant lessons for each task are auto-injected per prompt. ~${M(s)} tokens.)`}function at(e,t){return t?JSON.stringify({hookSpecificOutput:{hookEventName:e,additionalContext:t}}):""}function He(e,t){return e.map((r,n)=>({x:r,rang:n,gezeigt:t.includes(r.lektion)})).filter(({rang:r,gezeigt:n})=>r<pe||n).map(({x:r,rang:n,gezeigt:s})=>({thema:String(r.lektion.topic??""),rang:n,punkte:Math.round(r.punkte*1e3)/1e3,belege:r.belege,leser:typeof r.leser=="number"&&Number.isFinite(r.leser)?Math.round(r.leser*1e3)/1e3:null,gezeigt:s}))}async function ct(e,t,{nebenlauf:r,abrufMs:n,leser:s=!0,session:o=null,protokoll:i=!0,ereignis:c="UserPromptSubmit",editor:a="",lernen:l=!0,fetchFn:u}={}){const{lessons:p,quelle:d}=await $e(t,{nebenlauf:r,abrufMs:n,fetchFn:u}),m=de(),E=l&&m.aktiv&&c==="UserPromptSubmit"&&!!t.instanceId,h=E?he({instanceId:t.instanceId,sitzung:o,prompt:e,zaehlung:me(t.instanceId),einstellungen:m}):fe,T=O[h.arm]??O[0],g=await Y(e,p,t,{minBelege:ue,tiefe:s?K:0,zeitlimitMs:v,fetchFn:u}),f={...x(g.sortiert.filter(Z=>Z.belege>=T.minBelege),T.topK,600),leser:g.leser,leserMs:g.leserMs},N=h.kontrolle?"":Ue(f);if(E&&g.sortiert.length>0&&Ee(t.instanceId,o,_e({sitzung:be(o),zug:ye(e),ereignis:c,editor:a,arm:h.arm,kontrolle:h.kontrolle,erkundet:h.erkundet,ausgewaehlt:f.lessons.length,kandidatenZahl:g.sortiert.length,belege:f.belege,topScore:f.topScore,leser:f.leser,leserMs:f.leserMs,quelle:d,bestand:p.length,kandidaten:He(g.sortiert,f.lessons)})),i)try{V(Le,JSON.stringify({at:Date.now(),session:o,prompt_tokens:M(e),injected_tokens:N?f.tokens:0,matches:N?f.lessons.length:0,arm:h.arm,kontrolle:h.kontrolle,ausgewaehlt:f.lessons.length,top_score:f.topScore,belege:f.belege,leser:f.leser,leser_ms:f.leserMs,quelle:d,bestand:p.length})+`
|
|
8
|
+
`)}catch{}return{kontext:N,auswahl:f,quelle:d,bestand:p.length,entscheidung:h}}export{D as ABRUF_TIMEOUT_MS,J as ANZEIGE_ZEICHEN,gt as ARME,Ae as BESTAND_TTL_JUNG_MS,ve as BESTAND_TTL_KLEIN_MS,Se as BESTAND_TTL_MS,Ne as JUNG_ABRUF_MS,P as JUNG_FENSTER_MS,Ie as KLEIN_LEKTIONEN,v as LESER_HOOK_ZEITLIMIT_MS,Me as LESER_MAX_ZEICHEN,K as LESER_TIEFE,Le as NETZ_PROTOKOLL,ze as SITZUNG_TOP_N,ht as belohnungMelden,we as bestandFrist,q as bestandPfad,Ce as ergaenzeUmVorab,M as estimateTokens,$e as holeBestand,at as hookAusgabe,dt as lernEinstellungen,mt as lernenAuffrischen,G as leserAnfrageApi,ot as leserPunkteApi,Be as leserText,H as mischeMitLeser,ct as promptEinblendung,Ue as promptKontext,L as renderLesson,rt as resolveConfig,nt as schreibeVorabBestand,st as selectRelevant,it as selectRelevantMitLeser,xe as sicherungsPfad,lt as sitzungsKontext,Re as starteNebenlauf};
|